home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / ZIP_1_0.lha / src / variable.c < prev    next >
C/C++ Source or Header  |  1992-10-13  |  2KB  |  152 lines

  1. /*
  2.  * variable.c
  3.  *
  4.  * Variable manipulation routines
  5.  *
  6.  * Mark Howell 28-Jul-1992 V1.0
  7.  *
  8.  */
  9.  
  10. #include "ztypes.h"
  11.  
  12. /*
  13.  * load
  14.  *
  15.  * Load and store a variable value.
  16.  *
  17.  */
  18.  
  19. #ifdef __STDC__
  20. void load (zword_t variable)
  21. #else
  22. void load (variable)
  23. zword_t variable;
  24. #endif
  25. {
  26.  
  27.     store_operand (load_variable (variable));
  28.  
  29. }/* load */
  30.  
  31. /*
  32.  * push_var
  33.  *
  34.  * Push a value onto the stack
  35.  *
  36.  */
  37.  
  38. #ifdef __STDC__
  39. void push_var (zword_t value)
  40. #else
  41. void push_var (value)
  42. zword_t value;
  43. #endif
  44. {
  45.  
  46.     stack[--sp] = value;
  47.  
  48. }/* push_var */
  49.  
  50. /*
  51.  * pop_var
  52.  *
  53.  * Pop a variable from the stack.
  54.  *
  55.  */
  56.  
  57. #ifdef __STDC__
  58. void pop_var (zword_t variable)
  59. #else
  60. void pop_var (variable)
  61. zword_t variable;
  62. #endif
  63. {
  64.  
  65.     store_variable (variable, stack[sp++]);
  66.  
  67. }/* pop_var */
  68.  
  69. /*
  70.  * increment
  71.  *
  72.  * Increment a variable.
  73.  *
  74.  */
  75.  
  76. #ifdef __STDC__
  77. void increment (zword_t variable)
  78. #else
  79. void increment (variable)
  80. zword_t variable;
  81. #endif
  82. {
  83.  
  84.     store_variable (variable, load_variable (variable) + 1);
  85.  
  86. }/* increment */
  87.  
  88. /*
  89.  * decrement
  90.  *
  91.  * Decrement a variable.
  92.  *
  93.  */
  94.  
  95. #ifdef __STDC__
  96. void decrement (zword_t variable)
  97. #else
  98. void decrement (variable)
  99. zword_t variable;
  100. #endif
  101. {
  102.  
  103.     store_variable (variable, load_variable (variable) - 1);
  104.  
  105. }/* decrement */
  106.  
  107. /*
  108.  * increment_check
  109.  *
  110.  * Increment a variable and then check its value against a target.
  111.  *
  112.  */
  113.  
  114. #ifdef __STDC__
  115. void increment_check (zword_t variable, zword_t target)
  116. #else
  117. void increment_check (variable, target)
  118. zword_t variable;
  119. zword_t target;
  120. #endif
  121. {
  122.     short value;
  123.  
  124.     value = (short) load_variable (variable);
  125.     store_variable (variable, ++value);
  126.     conditional_jump (value > (short) target);
  127.  
  128. }/* increment_check */
  129.  
  130. /*
  131.  * decrement_check
  132.  *
  133.  * Decrement a variable and then check its value against a target.
  134.  *
  135.  */
  136.  
  137. #ifdef __STDC__
  138. void decrement_check (zword_t variable, zword_t target)
  139. #else
  140. void decrement_check (variable, target)
  141. zword_t variable;
  142. zword_t target;
  143. #endif
  144. {
  145.     short value;
  146.  
  147.     value = (short) load_variable (variable);
  148.     store_variable (variable, --value);
  149.     conditional_jump (value < (short) target);
  150.  
  151. }/* decrement_check */
  152.